﻿using System;

namespace Developer.Core.FrameWork.EventBus.Model
{
    /// <summary>
    /// 消息订阅模型
    /// </summary>
    public class SubscriptionInfo
    {
        /// <summary>
        /// 是否动态
        /// </summary>
        public bool IsDynamic { get; }

        /// <summary>
        /// 事件类型
        /// </summary>
        public Type HandlerType { get; }

        private SubscriptionInfo(bool isDynamic, Type handlerType)
        {
            IsDynamic = isDynamic;
            HandlerType = handlerType;
        }

        /// <summary>
        /// 动态
        /// </summary>
        /// <param name="handlerType"></param>
        /// <returns></returns>
        public static SubscriptionInfo Dynamic(Type handlerType)
        {
            return new SubscriptionInfo(true, handlerType);
        }

        /// <summary>
        /// 常规
        /// </summary>
        /// <param name="handlerType"></param>
        /// <returns></returns>
        public static SubscriptionInfo Typed(Type handlerType)
        {
            return new SubscriptionInfo(false, handlerType);
        }
    }
}
